﻿import { PagedRequestDto } from "@shared/component-base";

export interface IWeixinSettingDto {
  id:number;
  appId:string;
  appSecret:string;
  appUrl:string;
  appToken:string;
  appEncodingAESKey:string;
  miniProgramAppId:string;
  miniProgramSecret:string;
  merchantId:string;
}

export class WeixinSettingDto implements IWeixinSettingDto {
  id:number;
  appId:string;
  appSecret:string;
  appUrl:string;
  appToken:string;
  appEncodingAESKey:string;
  miniProgramAppId:string;
  miniProgramSecret:string;
  merchantId:string;

  constructor(data?: IWeixinSettingDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.id = data["id"];
      this.appId = data["appId"];
      this.appSecret = data["appSecret"];
      this.appUrl = data["appUrl"];
      this.appToken = data["appToken"];
      this.appEncodingAESKey = data["appEncodingAESKey"];
      this.miniProgramAppId = data["miniProgramAppId"];
      this.miniProgramSecret = data["miniProgramSecret"];
      this.merchantId = data["merchantId"];
      
    }
  }

  static fromJS(data: any): WeixinSettingDto {
    data = typeof data === 'object' ? data : {};
    let result = new WeixinSettingDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
      data["id"]=this.id;
      data["appId"]=this.appId;
      data["appSecret"]=this.appSecret;
      data["appUrl"]=this.appUrl;
      data["appToken"]=this.appToken;
      data["appEncodingAESKey"]=this.appEncodingAESKey;
      data["miniProgramAppId"]=this.miniProgramAppId;
      data["miniProgramSecret"]=this.miniProgramSecret;
      data["merchantId"]=this.merchantId;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new WeixinSettingDto();
    result.init(json);
    return result;
  }
}

export class WeixinSettingListQueryDto extends PagedRequestDto {
  phone: string;
  keywords: string;

  init(data?: any) {
    if (data) {
      this.pageIndex = data["pageIndex"];
      this.pageSize = data["pageSize"];
      this.sortField = data["sortField"];
      this.sortOrder = data["sortOrder"];
      this.keywords = data["keywords"];
    }
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["pageIndex"] = this.pageIndex;
    data["pageSize"] = this.pageSize;
    data["sortField"] = this.sortField;
    data["sortOrder"] = this.sortOrder;
    data["keywords"] = this.keywords;
    return data;
  }
}

export interface IWeixinSettingEditDto {
  id:number;
  appId:string;
  appSecret:string;
  appUrl:string;
  appToken:string;
  appEncodingAESKey:string;
  miniProgramAppId:string;
  miniProgramSecret:string;
  merchantId:string;
}

export class WeixinSettingEditDto implements IWeixinSettingEditDto {
  id:number;
  appId:string;
  appSecret:string;
  appUrl:string;
  appToken:string;
  appEncodingAESKey:string;
  miniProgramAppId:string;
  miniProgramSecret:string;
  merchantId:string;

  constructor(data?: IWeixinSettingEditDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.id = data["id"];
      this.appId = data["appId"];
      this.appSecret = data["appSecret"];
      this.appUrl = data["appUrl"];
      this.appToken = data["appToken"];
      this.appEncodingAESKey = data["appEncodingAESKey"];
      this.miniProgramAppId = data["miniProgramAppId"];
      this.miniProgramSecret = data["miniProgramSecret"];
      this.merchantId = data["merchantId"];
      
    }
  }

  static fromJS(data: any): WeixinSettingEditDto {
    data = typeof data === 'object' ? data : {};
    let result = new WeixinSettingEditDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
      data["id"]=this.id;
      data["appId"]=this.appId;
      data["appSecret"]=this.appSecret;
      data["appUrl"]=this.appUrl;
      data["appToken"]=this.appToken;
      data["appEncodingAESKey"]=this.appEncodingAESKey;
      data["miniProgramAppId"]=this.miniProgramAppId;
      data["miniProgramSecret"]=this.miniProgramSecret;
      data["merchantId"]=this.merchantId;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new WeixinSettingEditDto();
    result.init(json);
    return result;
  }
}


